import pytest

#from testRequest.Wework.weworkAdress import WeworkAdress
from weixin_app.weworkAdress import WeworkAdress


class TestAdress():
    name = "name_"
    userid = "tmp"
    def setup_class(self):

        self.adress = WeworkAdress()
        #self.userid = "zhangsan"
        #self.name = "张三"是的
        self.mobile = "+86 13800000001"
        self.department = [1]

    def setup(self):
        self.userid+="tem"
        self.name+="name"
        self.adress.del_user(self.userid)
    def teardown(self):
        self.adress.del_user(self.userid)

    def test_get_user(self):
        self.adress.add_user(self.userid,self.name,self.mobile,self.department)
        r = self.adress.get_user(self.userid)
        #assert  r["name"] == self.name d
    def test_add_user(self):
        r = self.adress.add_user(self.userid,self.name,self.mobile,self.department)
        assert  r['errmsg'] == 'created'

    @pytest.mark.parametrize("userid,newName",[["tmp",name+"tmp"]]*5)
    def test_update_user(self,userid,newName):
        userid=self.userid
        #name+=self.name
        self.adress.add_user(userid,self.name,self.mobile,self.department)
        r = self.adress.update_user(userid,newName)
        assert  r['errmsg'] == 'updated'

    def test_del_user(self):
        self.adress.add_user(self.userid,self.name,self.mobile,self.department)
        r = self.adress.del_user(self.userid)
        assert  r['errmsg'] == 'deleted'